package com.yhgm.mapper;

import com.yhgm.model.entity.Timer;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface TimerDao {
    @Insert("insert into timer(id, timer_id, job_name, corn, state, creation_time) VALUE (null,#{timerId},#{jobName},#{corn},1,#{creationTime})")
    Integer addOne(Timer timer);

    @Select("select count(id) from timer where timer_id=#{timerId}")
    Integer isJobExist(String timerId);

    @Select("select * from timer where id=#{id}")
    Timer getOneById(Long id);

    @Update("update timer set job_name=#{jobName}, corn=#{corn} where id=#{id}")
    Integer updateOneById(Timer timer);

    @Select("select timer_id from timer where id=#{id}")
    String getTimerIdById(Long id);

    @Delete("delete from timer where id=#{id}")
    Integer deleteOneById(Long id);

    @Update("update timer set state=#{state} where id=#{id}")
    Integer updateStateById(Integer state,Long id);

    List<Timer> multipleAndFuzzy(@Param("t") Timer timer, int page, int size);

    Integer countMultipleAndFuzzy(@Param("t")Timer timer);

    @Select("select * from timer where state=1")
    List<Timer> getTimerIsRunning();
}
